package com.spider.spiderorderadmin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spider.spiderorderadmin.common.Result;
import com.spider.spiderorderadmin.common.annotation.OperationAspect;
import com.spider.spiderorderadmin.entity.model.Feedback;
import com.spider.spiderorderadmin.entity.param.BaseQueryParam;
import com.spider.spiderorderadmin.service.FeedbackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author xiong.bo
 * @version 1.0
 * @date 2021/10/5 11:01 上午
 */
@Api(tags = "反馈意见模块")
@RequestMapping("/system/feedback")
@RestController
public class FeedbackController extends AbstractController {

    @Resource
    private FeedbackService feedbackService;

    @ApiOperation("反馈意见列表")
    @GetMapping
    public Result<Page<Feedback>> selectPage(BaseQueryParam queryParam) {
        return Result.of(feedbackService.selectPage(queryParam));
    }

    /**
     * 一般反馈意见可以是在web端和app端，
     * 因此创建人用户id交由前端传过来
     */
    @ApiOperation("新增意见反馈")
    @PostMapping
    @OperationAspect(accessPath = "/system/feedback/save", accessDesc = "新增意见反馈")
    public Result<Feedback> save(@RequestBody Feedback feedback) {
        return Result.of(feedbackService.saveFeedback(feedback));
    }

    @ApiOperation("处理意见反馈")
    @PostMapping("/handle")
    @OperationAspect(accessPath = "/system/feedback/handle", accessDesc = "处理意见反馈")
    public Result<Feedback> handle(@RequestBody Feedback feedback) {
        return Result.of(feedbackService.handleFeedback(feedback));
    }

}
